3. Aproximacion de las raices para 230 x^4 + 18 x^3 + 9 x^2 - 221 x -9

A partir de métodos gráficos podemos ver que existen dos reales en los intervalos (-0.5,0) y (0.5,1.5)

Método de bisección:


In [2]:
import math

def funcion(x):
    return (230*math.pow(x,4))+(18*math.pow(x,3))+(9*math.pow(x,2))-(221*x)-9

def biseccion(intA, intB, errorA, noMaxIter):
        if(funcion(intA)*funcion(intB)<0):
            noIter = 0
            errorTmp = 1
            intTmp = 0
            oldInt = intA
            while(noIter<noMaxIter and errorTmp>errorA and funcion(intTmp)!=0):
                
                intTmp = (intB+intA)/2
                if(funcion(intA)*funcion(intTmp)<0):
                    intB = intTmp
                else:
                    intA = intTmp
                noIter+=1
                errorTmp=abs((intTmp-oldInt)/intTmp)*100
                oldInt = intTmp
                #print('Error: ',errorTmp)
            print('La raíz es: ',intTmp)
            print('F(raiz) es:' ,funcion(intTmp))
            print('Error: ',errorTmp)
            print('No. de iteraciones realizadas: ',noIter)
        else:
            print('En el intervalo dado la función no presenta cambio de signo')
            print('No hay raices que encontrar')

print('------------------------------------')
print('Valores inicial : -0.5 y 0')
biseccion(-0.5,0,math.pow(10,-6),1000)
print('------------------------------------')
print('Valores iniciales : 0.5,1.5')
biseccion(0.5,1.5,math.pow(10,-6),1000)
print('------------------------------------')


------------------------------------
Valores inicial : -0.5 y 0
La raíz es:  -0.04065928817726672
F(raiz) es: -3.070432263996281e-08
Error:  5.726382681338949e-07
No. de iteraciones realizadas:  31
------------------------------------
Valores iniciales : 0.5,1.5
La raíz es:  0.9623984172940254
F(raiz) es: -9.706391495001299e-07
Error:  7.741680018419624e-07
No. de iteraciones realizadas:  27
------------------------------------

Método de regla falsa:

Debido al comportamiento de la función cerca a las raices (decrece y crece demasiado rápido) no fue posible usar este método para alcanzar una aproximación con precisión de 10^-6 aunque reducieramos los intervalos iniciales basándonos en los resultados del método de bisección (que si satisfacen la precisión).


In [1]:
import math

def funcion(x):
    return (230*math.pow(x,4))+(18*math.pow(x,3))+(9*math.pow(x,2))-(221*x)-9

def reglaFalsa(intA, intB, errorA, noMaxIter):
        if(funcion(intA)*funcion(intB)<0):
            noIter = 0
            errorTmp = 1
            intTmp = 0
            oldInt = intA
            while(noIter<noMaxIter and errorTmp>errorA and funcion(intTmp)!=0):
                intTmp = intB-((funcion(intB)*(intA+intB))/(funcion(intA)-funcion(intB)))
                if(funcion(intA)*funcion(intTmp)<0):
                    intB = intTmp
                else:
                    intA = intTmp
                noIter+=1
                errorTmp=abs((intTmp-oldInt)/intTmp)*100
                oldInt = intTmp
                #print('Error: ',errorTmp)
            print('La raíz es: ',intTmp)
            print('F(raiz) es:' ,funcion(intTmp))
            print('Error: ',errorTmp)
            print('No. de iteraciones realizadas: ',noIter)
        else:
            print('En el intervalo dado la función no presenta cambio de signo')
            print('No hay raices que encontrar')
            
print('------------------------------------')
print('Valores inicial : -0.5 y 0')
reglaFalsa(-0.5,0,math.pow(10,-6),1000)
print('------------------------------------')
print('Valores iniciales : 0.5,1.5')
reglaFalsa(0.5,1.5,math.pow(10,-6),1000)
print('------------------------------------')
print('Valores inicial : -0.2 y 0')
reglaFalsa(-0.2,0,math.pow(10,-6),1000)
print('------------------------------------')
print('Valores iniciales : 0.8,1')
reglaFalsa(0.8,1,math.pow(10,-6),1000)
print('------------------------------------')


------------------------------------
Valores inicial : -0.5 y 0
----------------------
0
-0.036036036036036036
-0.040735200624935096
-0.11156684453058816
-0.04503783641352737
-0.0776674532554304
-0.04864200062282384
-0.0670815616417693
-0.051374514589711553
-0.062371171820185554
-0.05329579316109511
-0.05995209987851402
-0.05457642096468335
-0.05861807846936599
-0.05539994748100467
-0.05785341228794739
-0.05591738441336154
-0.057405355295140986
-0.05623777684827812
-0.057139424914891504
-0.05643436713820883
-0.05698038634143911
-0.0565543218540669
-0.05688484141534579
-0.056627266211295775
-0.05682728474225056
-0.05667153167254587
-0.05679255544778655
-0.056698359856009115
-0.05677157929394322
-0.056714607333006095
-0.056758902331654384
-0.05672444245471385
-0.056751238229005296
-0.05673039430436361
-0.056746603736302303
-0.05673399553202217
-0.056743800882785994
-0.05673617426835289
-0.05674210563471918
-0.0567374923181988
-0.056741080249444076
-0.05673828965662891
-0.056740460018293915
-0.056738771985990095
-0.05674008484860682
-0.0567390637547161
-0.05673985791096019
-0.056739240248807395
-0.056739720637001265
-0.05673934701147577
-0.05673963760003614
-0.05673941159285992
-0.05673958737088902
-0.05673945065845817
-0.056739556987181895
-0.05673947428940521
-0.05673953860800348
-0.056739488583856273
-0.056739527490387874
-0.05673949723062138
-0.05673952076530947
-0.05673950246107955
-0.05673951669728898
-0.05673950562500134
-0.05673951423653065
-0.05673950753886813
-0.056739512748010146
-0.05673950869657245
-0.05673951184759933
-0.056739509396871564
-0.05673951130293793
-0.056739509820484785
-0.05673951097347049
-0.05673951007672979
-0.05673951077417458
La raíz es:  -0.05673951023173322
F(raiz) es: 3.567501930682381
Error:  9.560205111157903e-07
No. de iteraciones realizadas:  76
------------------------------------
Valores iniciales : 0.5,1.5
----------------------
0
3.29985082048732
7.0857358815127185
14.670167324285288
29.840192098740964
60.18036750008321
120.86073297882476
242.22146570897385
484.94293138710907
970.3858627703786
1941.271725540278
3883.043451080496
7766.586902160985
15533.67380432197
31067.84760864394
62136.19521728788
124272.89043457576
248546.28086915152
497093.06173830305
994186.6234766061
1988373.7469532122
3976747.9939064244
7953496.487812849
15906993.475625698
31813987.451251395
63627975.40250279
127255951.30500558
254511903.11001116
509023806.7200223
1018047613.9400446
2036095228.3800893
4072190457.2601786
8144380915.020357
16288761830.540714
32577523661.58143
65155047323.66286
130310094647.82571
260620189296.15143
521240378592.80286
1042480757186.1057
2084961514372.7114
4169923028745.923
8339846057492.346
16679692114985.191
33359384229970.883
66718768459942.266
133437536919885.03
266875073839770.56
533750147679541.6
1067500295359083.8
2135000590718168.0
4270001181436336.5
8540002362872674.0
1.7080004725745348e+16
3.4160009451490696e+16
6.832001890298139e+16
1.3664003780596278e+17
2.7328007561192557e+17
5.4656015122385114e+17
1.0931203024477023e+18
2.1862406048954045e+18
4.372481209790809e+18
8.744962419581618e+18
1.7489924839163236e+19
3.4979849678326473e+19
6.9959699356652945e+19
1.3991939871330589e+20
2.7983879742661178e+20
5.5967759485322356e+20
1.1193551897064471e+21
2.2387103794128943e+21
4.4774207588257885e+21
8.954841517651577e+21
1.7909683035303154e+22
3.581936607060631e+22
7.163873214121262e+22
1.4327746428242523e+23
2.8655492856485046e+23
5.731098571297009e+23
1.1462197142594019e+24
2.2924394285188037e+24
4.5848788570376074e+24
9.169757714075215e+24
1.833951542815043e+25
3.667903085630086e+25
7.335806171260172e+25
1.4671612342520344e+26
2.9343224685040688e+26
5.8686449370081375e+26
1.1737289874016275e+27
2.347457974803255e+27
4.69491594960651e+27
9.38983189921302e+27
1.877966379842604e+28
3.755932759685208e+28
7.511865519370416e+28
1.5023731038740832e+29
3.0047462077481664e+29
6.009492415496333e+29
1.2018984830992666e+30
2.403796966198533e+30
4.807593932397066e+30
9.615187864794132e+30
1.9230375729588265e+31
3.846075145917653e+31
7.692150291835306e+31
1.5384300583670612e+32
3.0768601167341224e+32
6.153720233468245e+32
1.230744046693649e+33
2.461488093387298e+33
4.922976186774596e+33
9.845952373549192e+33
1.9691904747098383e+34
3.9383809494196767e+34
7.876761898839353e+34
1.5753523797678707e+35
3.1507047595357413e+35
6.301409519071483e+35
1.2602819038142965e+36
2.520563807628593e+36
5.041127615257186e+36
1.0082255230514372e+37
2.0164510461028745e+37
4.032902092205749e+37
8.065804184411498e+37
1.6131608368822996e+38
3.226321673764599e+38
6.452643347529198e+38
1.2905286695058397e+39
2.5810573390116793e+39
5.1621146780233586e+39
1.0324229356046717e+40
2.0648458712093434e+40
4.129691742418687e+40
8.259383484837374e+40
1.6518766969674748e+41
3.3037533939349495e+41
6.607506787869899e+41
1.3215013575739798e+42
2.6430027151479596e+42
5.286005430295919e+42
1.0572010860591838e+43
2.1144021721183677e+43
4.2288043442367354e+43
8.457608688473471e+43
1.6915217376946941e+44
3.3830434753893883e+44
6.7660869507787766e+44
1.3532173901557553e+45
2.7064347803115106e+45
5.412869560623021e+45
1.0825739121246043e+46
2.1651478242492085e+46
4.330295648498417e+46
8.660591296996834e+46
1.7321182593993668e+47
3.4642365187987336e+47
6.928473037597467e+47
1.3856946075194934e+48
2.771389215038987e+48
5.542778430077974e+48
1.1085556860155948e+49
2.2171113720311895e+49
4.434222744062379e+49
8.868445488124758e+49
1.7736890976249516e+50
3.5473781952499032e+50
7.0947563904998064e+50
1.4189512780999613e+51
2.8379025561999226e+51
5.675805112399845e+51
1.135161022479969e+52
2.270322044959938e+52
4.540644089919876e+52
9.081288179839752e+52
1.8162576359679504e+53
3.632515271935901e+53
7.265030543871802e+53
1.4530061087743604e+54
2.9060122175487207e+54
5.8120244350974414e+54
1.1624048870194883e+55
2.3248097740389766e+55
4.649619548077953e+55
9.299239096155906e+55
1.8598478192311813e+56
3.7196956384623625e+56
7.439391276924725e+56
1.487878255384945e+57
2.97575651076989e+57
5.95151302153978e+57
1.190302604307956e+58
2.380605208615912e+58
4.761210417231824e+58
9.522420834463648e+58
1.9044841668927296e+59
3.808968333785459e+59
7.617936667570918e+59
1.5235873335141837e+60
3.0471746670283674e+60
6.094349334056735e+60
1.218869866811347e+61
2.437739733622694e+61
La raíz es:  inf
F(raiz) es: nan
Error:  nan
No. de iteraciones realizadas:  204
------------------------------------
Valores inicial : -0.2 y 0
----------------------
0
-0.04019292604501607
-0.0408849287694719
-0.09483332220125287
-0.041342358447178776
-0.07327352775251374
-0.04179021027859318
-0.0641285952794922
-0.04222344955339166
-0.05912076328499778
-0.04263797572561486
-0.05599058657492656
-0.04303050689694826
-0.053869534418362855
-0.043398596504321124
-0.05235248356731976
-0.04374062506377095
-0.05122499788167245
-0.044055751690349546
-0.050362916713833056
-0.044343831647557126
-0.04968934996908165
-0.04460531136542652
-0.04915412312214509
-0.04484111283253094
-0.048723094349585605
-0.04505251766356718
-0.04837222220983134
-0.04524105863485449
-0.04808408916846751
-0.04540842378265059
-0.04784577116612216
-0.045556375719745405
-0.04764748177878489
-0.04568668687547753
-0.04748168089869174
-0.045801089972062614
-0.04734247203381213
-0.0459012421788086
-0.04722518454280822
-0.045988700942438836
-0.04712607762044902
-0.046064909365244544
-0.04704212638466861
-0.046131189087817166
-0.04697086453193607
-0.046188738842276034
-0.04691026673258483
-0.046238637109569616
-0.0468586594414642
-0.046281847595535046
-0.04681465235772415
-0.04631922650693576
-0.046777085115254795
-0.04635153084547027
-0.046744985362928405
-0.04637942713845874
-0.04671753547187325
-0.046403500188960396
-0.04669404585517156
-0.04642426155812625
-0.04667393341203775
-0.046442157592933554
-0.046656703984226694
-0.046457576887897103
-0.046641937983773356
-0.04647085712460817
-0.046629278549461854
-0.04648229127225992
-0.04661842173595156
-0.04649213315931648
-0.04660910834891589
-0.04650060244418299
-0.04660111712210185
-0.04650788902355441
-0.04659425899510354
-0.04651415692296243
-0.04658837229899583
-0.04651954771636593
-0.04658331869448701
-0.04652418352154894
-0.04657897973660375
-0.04652816961642399
-0.046575253963080925
-0.04653159671869034
-0.04657205442204318
-0.046534542968097656
-0.046569306569316
-0.04653707564711896
-0.04656694647760196
-0.04653925267234974
-0.046564919309417155
-0.0465411238855594
-0.04656317801357279
-0.046542732170111956
-0.04656168221146666
-0.046544114415494844
-0.04656039724479855
-0.046545302349970355
-0.04655929336076072
-0.04654632325890126
-0.04655834501444894
-0.04654720060409395
-0.04655753027132943
-0.04654795455753733
-0.046556830295187875
-0.04654860246117694
-0.046556228909167184
-0.046549159222831975
-0.046555712219340274
-0.04654963765701935
-0.04655526829181907
-0.04655004877827366
-0.04655488687571969
-0.046550402053527104
-0.04655455916542252
-0.04655070561922124
-0.046554277596517264
-0.046550966468048134
-0.04655403567063368
-0.04655119060954601
-0.04655382780504926
-0.04655138320819331
-0.04655364920355459
-0.0465515487021413
-0.04655349574556117
-0.04655169090529048
-0.04655336389086643
-0.04655181309504071
-0.046553250597859606
-0.04655191808772059
-0.04655315325326705
-0.04655200830342236
-0.04655306961180595
-0.04655208582172751
-0.04655299774434649
-0.04655215242960108
-0.046552935993381284
-0.04655220966255357
-0.04655288293477056
-0.04655225884001588
-0.04655283734487776
-0.04655230109573987
-0.0465527981723353
-0.04655233740392355
-0.04655276451378773
-0.0465523686016617
-0.04655273559305136
-0.04655239540823843
-0.046552710743209255
-0.046552418441705594
-0.04655268939122754
-0.046552438233128816
-0.04655267104473813
-0.046552455238829185
-0.0465526552806825
-0.046552469850902264
-0.04655264173555455
-0.0465524824062571
-0.04655263009701698
-0.04655249319438312
-0.04655262009669833
-0.04655250246402412
-0.04655261150400381
-0.04655251042891294
-0.046552604120797605
-0.046552517272699157
-0.04655259777683368
-0.046552523153183235
-0.04655259232582995
-0.046552528205954735
-0.04655258764209498
-0.0465525325475185
-0.046552583617629595
-0.046552536277980866
-0.04655258015963648
-0.046552539483357754
-0.046552577188380365
-0.04655254223755795
-0.046552574635349384
-0.04655254460408721
-0.04655257244167527
-0.04655254663751253
-0.04655257055677596
-0.0465525483847203
-0.04655256893718916
-0.046552549885997406
-0.046552567545570286
-0.04655255117596011
-0.04655256634983124
-0.04655255228435223
-0.04655256532240056
-0.04655255323673098
-0.046552564439587704
-0.046552554055056226
-0.046552563681036704
-0.04655255475819686
-0.04655256302925685
-0.04655255536236587
-0.04655256246921939
-0.04655255588149412
-0.04655256198801095
-0.04655255632755168
-0.046552561574535814
-0.0465525567108237
-0.046552561219260075
-0.04655255704014766
-0.046552560913991764
-0.04655255732311711
-0.046552560651692
-0.04655255756625674
-0.04655256042631267
-0.04655255777517288
-0.046552560232656984
-0.046552557954682675
-0.046552560066259636
-0.04655255810892528
-0.046552559923283804
-0.04655255824145724
-0.04655255980043277
-0.046552558355334436
-0.046552559694873846
-0.046552558453182666
-0.04655255960417303
-0.04655255853725812
-0.04655255952623896
-0.046552558609499396
-0.04655255945927462
-0.046552558671572236
-0.04655255940173596
-0.046552558724907905
-0.04655255935229625
-0.046552558770736226
-0.046552559309815514
-0.04655255881011391
La raíz es:  -0.04655255927331422
F(raiz) es: 1.306884114089506
Error:  9.95005040905944e-07
No. de iteraciones realizadas:  235
------------------------------------
Valores iniciales : 0.8,1
----------------------
0
1.4690395305744288
3.542884902681404
7.876637627056537
16.552530817596423
33.904984991489805
68.6099612547973
138.01992146735557
276.8398428073522
554.4796855989633
1109.7593711959698
2220.3187423916957
4441.437484783361
8883.674969566717
17768.149939133433
35537.09987826686
71074.99975653373
142150.79951306747
284302.3990261349
568605.5980522698
1137211.9961045396
2274424.7922090795
4548850.384418159
9097701.568836316
18195403.937672634
36390808.67534527
72781618.15069054
145563237.10138106
291126475.00276214
582252950.8055243
1164505902.4110487
2329011805.622097
4658023612.044194
9316047224.88839
18632094450.57678
37264188901.95355
74528377804.7071
149056755610.21423
298113511221.22845
596227022443.2568
1192454044887.3137
2384908089775.4277
4769816179551.655
9539632359104.11
19079264718209.02
38158529436418.84
76317058872838.48
152634117745677.75
305268235491356.3
610536470982713.5
1221072941965427.8
2442145883930856.0
4884291767861713.0
9768583535723428.0
1.9537167071446856e+16
3.907433414289371e+16
7.814866828578742e+16
1.5629733657157485e+17
3.125946731431497e+17
6.251893462862994e+17
1.2503786925725988e+18
2.5007573851451976e+18
5.001514770290395e+18
1.000302954058079e+19
2.000605908116158e+19
4.001211816232316e+19
8.002423632464632e+19
1.6004847264929264e+20
3.200969452985853e+20
6.401938905971706e+20
1.2803877811943412e+21
2.5607755623886823e+21
5.121551124777365e+21
1.024310224955473e+22
2.048620449910946e+22
4.097240899821892e+22
8.194481799643783e+22
1.6388963599287567e+23
3.2777927198575134e+23
6.555585439715027e+23
1.3111170879430053e+24
2.6222341758860107e+24
5.244468351772021e+24
1.0488936703544043e+25
2.0977873407088085e+25
4.195574681417617e+25
8.391149362835234e+25
1.678229872567047e+26
3.356459745134094e+26
6.712919490268187e+26
1.3425838980536375e+27
2.685167796107275e+27
5.37033559221455e+27
1.07406711844291e+28
2.14813423688582e+28
4.29626847377164e+28
8.59253694754328e+28
1.718507389508656e+29
3.437014779017312e+29
6.874029558034624e+29
1.3748059116069248e+30
2.7496118232138495e+30
5.499223646427699e+30
1.0998447292855398e+31
2.1996894585710796e+31
4.399378917142159e+31
8.798757834284319e+31
1.7597515668568637e+32
3.5195031337137274e+32
7.039006267427455e+32
1.407801253485491e+33
2.815602506970982e+33
5.631205013941964e+33
1.1262410027883928e+34
2.2524820055767855e+34
4.504964011153571e+34
9.009928022307142e+34
1.8019856044614284e+35
3.603971208922857e+35
7.207942417845714e+35
1.4415884835691427e+36
2.8831769671382855e+36
5.766353934276571e+36
1.1532707868553142e+37
2.3065415737106284e+37
4.613083147421257e+37
9.226166294842514e+37
1.8452332589685027e+38
3.6904665179370054e+38
7.380933035874011e+38
1.4761866071748022e+39
2.9523732143496043e+39
5.904746428699209e+39
1.1809492857398417e+40
2.3618985714796835e+40
4.723797142959367e+40
9.447594285918734e+40
1.8895188571837468e+41
3.7790377143674936e+41
7.558075428734987e+41
1.5116150857469974e+42
3.023230171493995e+42
6.04646034298799e+42
1.209292068597598e+43
2.418584137195196e+43
4.837168274390392e+43
9.674336548780784e+43
1.9348673097561567e+44
3.8697346195123134e+44
7.739469239024627e+44
1.5478938478049254e+45
3.095787695609851e+45
6.191575391219701e+45
1.2383150782439403e+46
2.4766301564878806e+46
4.953260312975761e+46
9.906520625951522e+46
1.9813041251903045e+47
3.962608250380609e+47
7.925216500761218e+47
1.5850433001522436e+48
3.170086600304487e+48
6.340173200608974e+48
1.2680346401217949e+49
2.5360692802435897e+49
5.072138560487179e+49
1.0144277120974359e+50
2.0288554241948718e+50
4.0577108483897435e+50
8.115421696779487e+50
1.6230843393558974e+51
3.246168678711795e+51
6.49233735742359e+51
1.298467471484718e+52
2.596934942969436e+52
5.193869885938872e+52
1.0387739771877743e+53
2.0775479543755487e+53
4.155095908751097e+53
8.310191817502195e+53
1.662038363500439e+54
3.324076727000878e+54
6.648153454001756e+54
1.3296306908003512e+55
2.6592613816007023e+55
5.318522763201405e+55
1.063704552640281e+56
2.127409105280562e+56
4.254818210561124e+56
8.509636421122247e+56
1.7019272842244495e+57
3.403854568448899e+57
6.807709136897798e+57
1.3615418273795596e+58
2.723083654759119e+58
5.446167309518238e+58
1.0892334619036477e+59
2.1784669238072953e+59
4.356933847614591e+59
8.713867695229181e+59
1.7427735390458363e+60
3.4855470780916726e+60
6.971094156183345e+60
1.394218831236669e+61
2.788437662473338e+61
La raíz es:  inf
F(raiz) es: nan
Error:  nan
No. de iteraciones realizadas:  205
------------------------------------

Método de Newton - Raphson:


In [8]:
import math

def funcion(x):
    return (230*math.pow(x,4))+(18*math.pow(x,3))+(9*math.pow(x,2))-(221*x)-9

def funcionDeriv(x):
    return (920*math.pow(x,3))+(54*math.pow(x,2))+(18*x)-221

def newtonRaphson(val, errorA, noMaxIter):
    noIter = 0
    errorTmp = 1
    intTmp = 0
    while(noIter<noMaxIter and errorTmp>errorA and funcion(intTmp)!=0):
        valTmp = val-((funcion(val))/(funcionDeriv(val)))
        errorTmp=abs((valTmp-val)/valTmp)*100
        val = valTmp
        noIter+=1
    print('La raíz es: ',valTmp)
    print('F(raiz) es:' ,funcion(valTmp))
    print('Error: ',errorTmp)
    print('No. de iteraciones realizadas: ',noIter)
print('------------------------------------')
print('Valores inicial : -0.5')
newtonRaphson(-0.5,math.pow(10,-6),1000)
print('------------------------------------')
print('Valores iniciales : 1.5')
newtonRaphson(1.5,math.pow(10,-6),1000)
print('------------------------------------')


------------------------------------
Valores inicial : -0.5
La raíz es:  -0.040659288315758865
F(raiz) es: 1.7763568394002505e-15
Error:  3.07187103965912e-13
No. de iteraciones realizadas:  5
------------------------------------
Valores iniciales : 1.5
La raíz es:  0.9623984187505414
F(raiz) es: 0.0
Error:  2.999360563967866e-13
No. de iteraciones realizadas:  7
------------------------------------

Método de secante:


In [9]:
import math

def funcion(x):
    return (230*math.pow(x,4))+(18*math.pow(x,3))+(9*math.pow(x,2))-(221*x)-9

def secante(primerVal, segundoVal, errorA, noMaxIter):
    noIter = 0
    errorTmp = 1
    intTmp = 0
    while(noIter<noMaxIter and errorTmp>errorA and funcion(segundoVal)!=0):
        valTmp = segundoVal-((funcion(segundoVal)*(primerVal-segundoVal))/(funcion(primerVal)-funcion(segundoVal)))
        primerVal = segundoVal
        segundoVal = valTmp
        errorTmp=abs((segundoVal-primerVal)/segundoVal)*100
        #print('Noiter: ',noIter, ' primVal:', primerVal,' segunVal:',segundoVal,' error:',errorTmp)
        noIter+=1
    print('La raíz es: ',valTmp)
    print('F(raiz) es:' ,funcion(valTmp))
    print('Error: ',errorTmp)
    print('No. de iteraciones realizadas: ',noIter)
    
print('------------------------------------')
print('Valores inicial : -0.5 y 0')
secante(-0.5,0,math.pow(10,-6),1000)
print('------------------------------------')
print('Valores iniciales : 0.5,1.5')
secante(0.5,1.5,math.pow(10,-6),1000)
print('------------------------------------')


------------------------------------
Valores inicial : -0.5 y 0
La raíz es:  -0.040659288315758865
F(raiz) es: 1.7763568394002505e-15
Error:  1.0239570132197068e-12
No. de iteraciones realizadas:  5
------------------------------------
Valores iniciales : 0.5,1.5
La raíz es:  0.9623984187505414
F(raiz) es: 0.0
Error:  3.6083461184750345e-10
No. de iteraciones realizadas:  14
------------------------------------

Conclusión

En los resultados anteriores se pudo comprobar la superioridad de los métodos abiertos a la hora de encontrar las dos raices de la función, especialmente el del método de Newton - Raphson que tuvo una leve mejora a la hora de aproximar la segunda raíz en menos iteraciones.